class Solution {
    vector<vector<int>> ret;
    vector<int> tmp;
    bool used[6] = {0};
 
    void dfs(vector<int>& nums)
    {
        if (tmp.size() == nums.size())
        {
            ret.push_back(tmp);
            return;
        }

        for (int i = 0; i < nums.size(); i++)
        {
            if (!used[i])
            {
                tmp.push_back(nums[i]);
                used[i] = true;
                dfs(nums);
                tmp.pop_back();
                used[i] = false;
            }
            
        }

    }
public:
    vector<vector<int>> permute(vector<int>& nums) {
        dfs(nums);

        return ret;
    }
};